﻿CREATE FUNCTION [dbo].[UserName]
(
	@UserID int
)
RETURNS varchar(100)
AS
BEGIN
	declare @ret varchar(100)
	select @ret = [SYSTEM_USER] from master..tblSalesManagerUser where UserID = @UserID
	return case when charindex( '\', @ret ) > 0 then substring( @ret, charindex( '\', @ret ) + 1, len( @ret ) - charindex( '\', @ret ) ) else @ret end
END